package com.pzhuweb.sgblog.controller;

import com.pzhuweb.sgblog.domain.utils.ResponseResult;
import com.pzhuweb.sgblog.service.UploadService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.io.IOException;

/**
 * @author 鄧浩奇
 * @classname UpLoadController
 * @description
 * @since 2023/8/16 17:22
 **/

@RestController
@Api(tags = "UpLoadController",description = "图片上传")
public class UpLoadController {

    @Resource
    private UploadService uploadService;

    @ApiOperation(value = "上传图片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "img",value = "图片文件",dataTypeClass = File.class,paramType = "form")
    })
    @PostMapping("/upload")
    public ResponseResult<?> uploadImg(@RequestParam("img") MultipartFile img) {
            return uploadService.uploadImg(img);
    }
}
